 <?php 

$username = $_GET['username'];
//$username='trang';
$actives = ($_GET['actives']!='false')? "'Active', ": "";
$pendings = ($_GET['pendings']!='false')? "'Pending', ": "";
$solds = ($_GET['solds']!='false')? "'Sold'": "";
// $withdrawn = ($_GET['withdrawn']!='false')? "'Withdrawn'": "";

$city_name = $_GET['fl_city'];

//$in = $actives.$pendings.$solds.$withdrawn;
$in = $actives.$pendings.$solds.$withdrawn;

$in = trim($in);
$in = rtrim($in, ',');
$in = "(".$in.")";
//echo $in;

include("../db/opendb.php");

include("functions.php");

if($city_name != '')
{
$query = "select i.Path as IMAGE, l.OID, l.TITLE, l.LISTSTATUS, l.STREETNUM, l.STREETDIR, l.STREETNAME, l.STREETSUFFIX, l.CITY, l.STATE, l.BEDS, l.BATHSTOTAL, l.SQFTTOTAL, l.PARKINGCOVERED, l.LISTPRICE from PROPERTIES l inner join Prop_Owner_Con p on p.Prop_OID = l.OID inner join Users u on u.ID = p.Owner left join Listing_Images i on (i.Listing_ID = l.OID and i.Main_Photo = 1) where u.Username = '".$username."' and l.CITY='".$city_name."' and l.LISTSTATUS in ".$in." order by l.sort_order, l.LISTSTATUS";
}
else
{
$query = "select i.Path as IMAGE, l.OID, l.TITLE, l.LISTSTATUS, l.STREETNUM, l.STREETDIR, l.STREETNAME, l.STREETSUFFIX, l.CITY, l.STATE, l.BEDS, l.BATHSTOTAL, l.SQFTTOTAL, l.PARKINGCOVERED, l.LISTPRICE from PROPERTIES l inner join Prop_Owner_Con p on p.Prop_OID = l.OID inner join Users u on u.ID = p.Owner left join Listing_Images i on (i.Listing_ID = l.OID and i.Main_Photo = 1) where u.Username = '".$username."' and l.LISTSTATUS in ".$in." order by l.sort_order, l.LISTSTATUS";
}

$result = mysql_query($query) or die ("SQL Error".mysql_error());

$xml = getXML($result);

echo $xml;

?>
